﻿using System;

namespace Fermat
{
    class Program
    {
        /// <summary>
        /// 验证当x,y,z小于等于10000时，x^3+y^3=z^3是否有整数解，即费马大定理是否成立
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            int Max = 10000;
            long[] num = new long[Max];
            for (int i = 0; i < Max; i++)
            {
                num[i] = i * i * i;
            }
            bool Flag = true;
            for (int i = 0; i < Max && Flag; i++)
            {
                for (int j = i; j < Max && Flag; j++)
                {
                    for (int k = j + 1; k < Max && Flag; k++)
                    {
                        if (num[i] + num[j] == num[k])//两项之和
                            Flag = false;
                    }
                }
            }
            if (!Flag)
            {
                Console.WriteLine("费马大定理成立");
            }
            else
            {
                Console.WriteLine("费马大定理不成立");
                Console.ReadKey();
            }
        }
    }
}
